package com.lizardmind.haofudoctor.test

import android.content.Context
import android.databinding.ViewDataBinding
import android.os.Bundle
import android.support.annotation.LayoutRes
import android.support.v4.view.ViewPager
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewManager
import android.widget.LinearLayout
import com.linxiao.framework.activity.BaseActivity
import com.linxiao.framework.adapter.DividerGridItemDecoration
import com.linxiao.framework.util.color
import com.linxiao.framework.util.getBaseFragmentStatePagerAdapter
import com.linxiao.framework.util.ke
import com.lizardmind.haofudoctor.R
import com.lizardmind.haofudoctor.databinding.ItemChuFangBinding
import com.lizardmind.haofudoctor.databinding.ItemCustomChuFangBinding
import com.lizardmind.haofudoctor.manager.postApi
import com.lizardmind.haofudoctor.other.*
import com.lizardmind.haofudoctor.ui.diagnosis.visit.LookVisitActivity
import com.lizardmind.haofudoctor.ui.diagnosis.visit.SendVisitActivity
import com.lizardmind.haofudoctor.ui.diagnosis.visit.userFill.FillVisitActivity
import io.reactivex.functions.Consumer
import me.drakeet.multitype.Items
import me.drakeet.multitype.MultiTypeAdapter
import org.jetbrains.anko.AnkoViewDslMarker
import org.jetbrains.anko.button
import org.jetbrains.anko.custom.ankoView
import org.jetbrains.anko.linearLayout
import org.jetbrains.anko.sdk25.coroutines.onClick
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.support.v4.startActivity
import org.jetbrains.anko.support.v4.viewPager

/**
 *
 * Created by Extends on 2017/11/3 16:26
 */
class TestActivity:BaseActivity() {
    private lateinit var rv: RecyclerView
    private val apt = MultiTypeAdapter()
    var idd:String = "0"
    override fun onCreatRootView(): View? {
        return linearLayout {
            orientation = LinearLayout.VERTICAL
            button("发送随访问诊单") { onClick { startActivity<SendVisitActivity>("uid" to "1")} }
            button("填写随访问诊单") { onClick {startActivity<FillVisitActivity>("id" to "1")} }
            button("查看随访问诊单") { onClick {startActivity<LookVisitActivity>("id" to "1")} }

            rv = recyclerView {
                id = R.id.test_recycler
                layoutManager = LinearLayoutManager(context)
                adapter = apt
                addItemDecoration(DividerGridItemDecoration(context, 2f, context.color(R.color.windowBackground)))
            }
        }
    }

    override fun onInitView(savedInstanceState: Bundle?) {
//        apt.register(ChuFangBean::class.java,BaseBinder<ChuFangBean,ItemChuFangBinding>(R.layout.item_chu_fang))
        apt.register<ChuFangBean,ItemChuFangBinding>(R.layout.item_chu_fang)
        apt.register<CustomChuFangMedicalBean,ItemCustomChuFangBinding>(R.layout.item_custom_chu_fang)

        val item = Items()
        item.add(ChuFangBean("","","111111111111111111111111","","111111"))
        item.add(CustomChuFangMedicalBean("aaaaaaaaaaaaaaaaa",""))
        item.add(ChuFangBean("","","111111111111111111111111","","222222"))
        item.add(CustomChuFangMedicalBean("bbbbbbbbbbbbbbbbb",""))
        item.add(ChuFangBean("","","111111111111111111111111","","333333"))
        item.add(CustomChuFangMedicalBean("ccccccccccccccccc",""))
        item.add(ChuFangBean("","","111111111111111111111111","","44444444"))
        item.add(CustomChuFangMedicalBean("ddddddddddddddddd",""))
        item.add(ChuFangBean("","","111111111111111111111111","","5555555"))
        item.add(CustomChuFangMedicalBean("eeeeeeeeeeeeeeeee",""))
        apt.items = item
        apt.notifyDataSetChanged()
    }
}

